package com.drools.demo.server;

import com.drools.demo.entity.Person;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author czq
 * @Package com.drools.demo.server
 * @Date 2024/8/28 15:00
 * @description:
 */
@Service
public class ExtendsService {
    @Autowired
    private KieContainer kieContainer;

    public void executeRules() {
        Person person1 = new Person();
        person1.setAge(20);
        person1.setName("hi");


        KieSession kieSession = kieContainer.newKieSession();
        kieSession.getAgenda().getAgendaGroup("extends_rule1").setFocus();
        kieSession.insert(person1);

        kieSession.fireAllRules();
        kieSession.dispose();
    }
}
